<?php
/**
 * This file is part of Task Agile.
 * Task Agile is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License.
 * Task Agile is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Task Agile.  If not, see <http://www.gnu.org/licenses/>.
 *
 * @category   TaskAgile
 * @package    Controller
 * @copyright  Copyright (c) 20010-2010 Estrada Virtual (http://estradavirtual.com.br)
 * @license    http://www.gnu.org/licenses/gpl.txt GPLv3
 * @version    $Id$
*/
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
    protected function _initAutoLoader()
    {
        $autoloader = Zend_Loader_Autoloader::getInstance();
        return $autoloader->setFallbackAutoloader(true);
    }

    protected function _initNavigation()
    {
        $this->bootstrap('layout');
        $layout = $this->getResource('layout');
        $view = $layout->getView();
        $config = new Zend_Config_Xml(APPLICATION_PATH . '/configs/navigation.xml', 'nav');

        $container = new Zend_Navigation($config);

        $view->navigation($container);
        return $container;
    }

    protected function _initCacheAdapters()
    {
        $cache = $this->bootstrap('cachemanager')->getContainer()->cachemanager->getCache('default');
        Zend_Translate::setCache($cache);
        Zend_Db_Table::setDefaultMetadataCache($cache);

        // bootstrap cache
        $cacheManager = $this->getResource('cachemanager');
        Zend_Registry::set('Zend_Cache_Manager', $cacheManager);
    }

    protected function _initDbFetchMode()
    {
        $this->bootstrap('db');
        Zend_Db_Table::getDefaultAdapter()->setFetchMode(Zend_Db::FETCH_OBJ);
    }
}
